<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="lib/css/bootstrap.css">
    <title>登录</title>
    <style>
        .container-box{
            margin-top: 70px;
        }
    </style>
</head>

<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
                    aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">登录页面</a></li>
                    
                </ul>

            </div>
            
        </div>
    </nav>

    <div class="container container-box">
        <form>
            <div class="form-group">
                <label for="username">用户名：</label>
                <input type="text" class="form-control" name="username" id="username">
            </div>
            <div class="form-group">
                <label for="psw">密码：</label>
                <input type="password" class="form-control" name="psw" id="psw">
            </div>
            
            <div class="modal-footer">
                <input type="submit" class="btn btn-primary btn-lg save" value="登录">
            </div>
        </form>
    </div>

    <script src="lib/jquery.js"></script>
    <script src="lib/js/bootstrap.js"></script>

    <script>
        $("form").submit(function(e){
            e.preventDefault();

            $.post("/login",$(this).serialize(),(res)=>{
                console.log(res);
                if(res.code == "success"){
                    location.href = "user.html"
                }else{
                    alert(res.msg);
                }

                
            })
        })
    </script>
</body>

</html>